/**
 * 日志工具
 *
 * @data 2025 6月18
 * @author : Mr.xie
 */
const colors = require('colors-console');

const Logger = {

    e(message) {
        printLog(message, 'red')
    },

    i(message) {
        printLog(message, 'cyan')
    },
    d(message) {
        printLog(message, 'green')
    },
    w(message) {
        printLog(message, "yellow")
    },
    log(message){
        console.log(colors("bright", message));
    }
}

function printLog(message, colorCode) {
    const style = `
        color: ${colorCode}; 

        padding: 2px 4px; 
        border-radius: 4px;
        font-weight: bold;
    `;

    // 获取字符串长度
    const length = message.length;
    // 构造边框线，长度为字符串长度加2（两侧各留一个空格）
    const border = '=='.repeat(length * 2);
    // 构造日志内容，两侧各加一个空格
    const logContent = ` ${message} `;
    // 输出带有边框的日志
    console.log(colors(colorCode, border));
    console.log(colors(colorCode, logContent));
    console.log(colors(colorCode, border));
}


module.exports = Logger




